package com.mt.roll.wms.controller;

import com.baomidou.mybatisplus.core.incrementer.DefaultIdentifierGenerator;
import com.mt.roll.core.base.BaseController;
import com.mt.roll.core.constants.CommonConstant;
import com.mt.roll.core.dal.entity.StorageBoxCircInfo;
import com.mt.roll.core.validator.groups.AddGroup;
import com.mt.roll.core.vo.IdVo;
import com.mt.roll.core.vo.R;
import com.mt.roll.opcua.s7.my.s7connector.api.DaveArea;
import com.mt.roll.opcua.s7.my.s7connector.enmuc.S7Client;
import com.mt.roll.opcua.s7.my.s7connector.service.S7Service;
import com.mt.roll.wms.dispatch.enums.machineHand1.MachineHand1Plc2WcsVarEnum;
import com.mt.roll.wms.dispatch.enums.machineHand1.MachineHand1Wcs2PlcVarEnum;
import com.mt.roll.wms.params.RobotParam;
import com.mt.roll.wms.params.WorkOrderParam;
import com.mt.roll.wms.service.RobotService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.groups.Default;

/**
 * @Author weihongyang
 * @Date 2021/11/9 10:58 上午
 * @Version 1.0
 */
@RestController
@RequestMapping(CommonConstant.API_MODULE_WMS + "robot")
@Slf4j
@Api(value = "机器人接口", tags = "机器人接口", hidden = false)
public class RobotController extends BaseController {

    @Autowired
    private RobotService robotService;

    @Autowired
    private S7Service s7Service;

    @PostMapping(value = "stacker/task")
    @ApiOperation(value = "堆垛机发任务")
    private R<IdVo> stackerTask(@Validated({AddGroup.class, Default.class}) @RequestBody RobotParam robotParam) {
        return robotService.stackerTask(robotParam);
    }


    @PostMapping(value = "test")
    @ApiOperation(value = "测试")
    private R test() {
        DefaultIdentifierGenerator defaultIdentifierGenerator = new DefaultIdentifierGenerator();
        Long aLong = defaultIdentifierGenerator.nextId(new StorageBoxCircInfo());
        System.out.println(aLong);
        return R.ok("");
    }
}
